<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="container-fluid">
<div class="row">
	<div class="col-12">
		<div class="card">
			<div class="card-body">
				<div class="media">
					<div>
						<img src="<?php echo FALSE !== strpos($plugin['icon_url'], 'http') ? $plugin['icon_url'] : '../'.$plugin['icon_url']; ?>" width="54" height="54" class="mr-3" />
					</div>
					<div class="media-body">
						<h4>
                            <?php echo $plugin['name']; ?><span class="mx-1">v<?php echo $plugin['version']; ?></span>
							<?php if($plugin['have_upgrade']) { ?>
							<span class="text-danger">v<?php echo $plugin['official_version']; ?></span>
							<?php } ?>
                        </h4>
						<p>
                            <?php echo $plugin['brief']; ?>
                        </p>
						<?php if(!empty($plugin['storeid'])) { ?>
                        <p>
                            <span class="text-muted"><?php echo lang('brief');?></span>：
                            <span><a href="<?php echo $plugin['brief_url']; ?>" target="_blank"><?php echo $plugin['brief_url']; ?></a></span>
                        </p>
                        <?php } ?>
					</div>
				</div>
				<hr />
				<div class="row line-height-3">
					<div class="col-md-6">
						<span class="text-muted"><?php echo lang('plugin_dir');?></span>：
						<?php echo $dir; ?>
					</div>

					<div class="col-md-6">
						<span class="text-muted"><?php echo lang('plugin_version');?></span>：
						<?php echo $plugin['software_version']; ?>
					</div>

					<?php if(!empty($plugin['storeid'])) { ?>
					<div class="col-md-6">
						<span class="text-muted"><?php echo lang('price');?></span>：
						<i class="icon-rmb"></i>
						<?php echo isset($return['price'])?$return['price']:$plugin['official']['price']; ?>
					</div>

					<div class="col-md-6">
						<span class="text-muted"><?php echo lang('installs');?></span>：
						<span><?php echo $plugin['downloads']; ?></span>
					</div>

					<?php  } ?>
				</div>
				<hr />
				<!-- FALSE === $verify_token 登录-->
                <?php if(FALSE === $verify_token) { ?>
                <div class="col-md-4 mx-auto">
                    <p class="text-danger text-center font-weight-bold">
						<?php echo lang('plugin_login_tips');?>
                    </p>
                    <div class="ajax_modal_body">
                        <form action="<?php echo url('plugin-read', $extra, TRUE);?>" method="post" id="form">
                            <div class="form-group input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="icon icon-user icon-fw"></i></span>
                                </div>
                                <input type="text" class="form-control" placeholder="<?php echo lang('email');?> / <?php echo lang('username');?>" id="email" name="email">
                                <div class="invalid-feedback"></div>
                            </div>
                            <div class="form-group input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="icon icon-lock icon-fw"></i></span>
                                </div>
                                <input type="password" class="form-control" placeholder="<?php echo lang('password');?>" id="password" name="password">
                                <div class="invalid-feedback"></div>
                            </div>
                            <div class="form-group">
                                <button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="<?php echo lang('submiting');?>...">
                                    <?php echo lang('login');?>
                                </button>
                            </div>
                            <div class="media">
                                <div class="media-body text-right">
                                    <a target="_blank" href="http://www.wellcms.cn/" class="text-muted">
                                        <small>
                                            <?php echo lang('user_create');?>
                                        </small>
                                    </a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <?php }else{ ?>
                <p class="mt-3 text-center text-danger">
                    <?php echo lang('plugin_read_tips'); ?>
                </p>
                <?php } ?>

				<?php if($errstr) { ?>
				<div class="alert alert-primary text-center">
					<?php echo $errstr; ?>
				</div>
				<?php } ?>

				<?php if(FALSE !== $return && 1 == $return['code']) { ?>
				<div class="row my-3">
					<div class="col-12 text-center">
						<span class="font-weight-bold text-danger m-3">
							<?php echo $payment_tips; ?>
						</span>
                        <br>
                        <a role="button" rel="nofollow" data-modal-title="<?php echo lang('buy_application'),'&nbsp;',lang('payment'),'&nbsp;',$payment_tips;?>" class="btn btn-primary buy mx-1" href="<?php echo url('plugin-buy', array('dir'=>$dir,'safe_token' => $safe_token), TRUE); ?>"><?php echo lang('buy');?></a>
					</div>
				</div>
				<?php } ?>

				<p class="text-center">
					<?php if($download_url && !$islocal) { ?>
						<a role="button" class="btn btn-primary mx-1" href="<?php echo $download_url; ?>"><?php echo lang('download');?></a>
					<?php } ?>

					<?php if($plugin['setting_url']) { ?>
					<a role="button" class="btn btn-primary mx-1" href="<?php echo url('plugin-setting', array('dir'=>$dir,'safe_token' => $safe_token), TRUE); ?>"><?php echo lang('setting');?></a>
					<?php } ?>

					<?php if($islocal && !$plugin['installed'] && 1 != $plugin['type']) { ?>
					<a role="button" class="btn btn-success mx-1" href="<?php echo url('plugin-install', array('dir'=>$dir,'safe_token' => $safe_token), TRUE); ?>"><?php echo lang('install');?></a>
					<?php } ?>

					<?php if($plugin['installed'] && $plugin['enable'] && 1 != $plugin['type']) { ?>
					<a role="button" class="btn btn-secondary mx-1" href="<?php echo url('plugin-disable', array('dir'=>$dir,'safe_token' => $safe_token), TRUE); ?>"><?php echo lang('disable');?></a>
					<?php } ?>

					<?php if($plugin['installed'] && !$plugin['enable'] && 1 != $plugin['type']) { ?>
					<a role="button" class="install btn btn-secondary mx-1" data-href="<?php echo url('plugin-enable', array('dir'=>$dir,'safe_token' => $safe_token), TRUE); ?>" href="javascript:void(0);"><?php echo lang('enable');?></a>
					<?php } ?>

					<?php if($plugin['installed'] && 1 != $plugin['type']) { ?>
                    <a role="button" class="btn btn-danger confirm mx-1" data-method="post" data-confirm-text="<?php echo lang('plugin_uninstall_confirm_tips', array('name'=>$plugin['name']));?>" href="<?php echo url('plugin-uninstall', array('dir'=> $dir, 'safe_token' => $safe_token), TRUE); ?>"><?php echo lang('uninstall');?></a>
					<?php } ?>

                    <?php if($islocal && !$plugin['installed'] && 1 == $plugin['type']) { ?>
                    <a role="button" class="btn btn-primary mx-1 install" data-href="<?php echo url('plugin-theme', array('dir'=>$dir,'type'=>1,'safe_token' => $safe_token), TRUE);?>" href="javascript:void(0);"><?php echo lang('install');?></a>

                    <?php } ?>

                    <?php if($plugin['installed'] && 1 == $plugin['type']) { ?>
                    <a role="button" class="uninstall btn btn-danger mx-1" data-method="post" data-confirm-text="<?php echo lang('plugin_uninstall_confirm_tips', array('name'=>$plugin['name']));?>" data-href="<?php echo url('plugin-theme', array('dir'=>$dir,'type'=>0), TRUE);?>" href="javascript:void(0);"><?php echo lang('uninstall');?></a>
                    <?php } ?>

					<?php if($plugin['have_upgrade']) { ?>
					<a role="button" class="btn btn-primary mx-1 upgrade" href="<?php echo url('plugin-upgrade', array('dir'=>$dir,'safe_token' => $safe_token), TRUE); ?>"><?php echo lang('update');?></a>
					<?php } ?>

				</p>
		    </div>
		</div>
    </div>
</div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script>
    var jform = $('#form');
    jform.on('submit', function() {
        jform.reset();
        var jthis = $(this);
        var jsubmit = jthis.find('#submit');
        jsubmit.button('loading');
        var postdata = jform.serializeObject();
        $.xpost(jform.attr('action'), postdata, function(code, message) {
            if(code == 0) {
                jsubmit.button(message).delay(1000).location();
            } else if(xn.is_number(code)) {
                $.alert(message);
                jsubmit.button('reset');
            } else {
                jform.find('[name="'+code+'"]').alert(message).focus();
                jsubmit.button('reset');
            }
        });
        return false;
    });

    $('#plugin').addClass('show');
    $('li.plugin, .menu-plugin').addClass('active').find('a').removeClass('collapsed');
</script>